﻿--[[
	Widget name	  	AddonList
	Author     	 	Kurapica
--]]
     
-- AddonList
do    
    local getmetatable = getmetatable
    local pairs = pairs
    local ipairs = ipairs
    local type = type
    local error = error
    local floor = floor
	local tostring = tostring
	local random = random
	local tinsert = table.insert
	local tremove = table.remove
	local wipe = table.wipe
    local CreateFrame = IGAS.GUI.CreateFrame
    
	local _WidgetName = "AddonList"
	local _Base = IGAS.GUI.Widget.Frame

    local _Widget = IGAS.Studio.Widget
    local _PropertyType = IGAS.GUI.Base.PropertyType
	
    ------------------------------------------------------
	---------------------   AddonList   -------------------
	------------------------------------------------------
	local _WidgetName = "AddonList"
    local _Base = "Frame"

    -- Scripts
	local _FrameBackdrop = {
        bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
        edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
        tile = true, tileSize = 16, edgeSize = 16,
        insets = { left = 3, right = 3, top = 3, bottom = 3 }
	}
	
	-- Frame
	local function OnMouseDown(self)
		self:StartMoving()
	end

	local function OnMouseUp(self)
		self:StopMovingOrSizing()
	end
	
	-- Sizer-SouthEast	
	local function sizerseOnMouseDown(self)
		if self:GetParent().Resizable then
			self:GetParent():StartSizing("BOTTOMRIGHT")
		end
	end
	
	local function sizerOnMouseUp(self)
		self:GetParent():StopMovingOrSizing()
	end
	
	-- ScriptType
	local _ScriptType = {
	}
	    
	-- FuncProxy
	local _FuncProxy = {
		["Refresh"] = function(self)
			
		end,
    }
    
	-- Property
	local _Property = {
    }
    
    -- New    
    local _New = function(parent)
        local frame = CreateFrame(_Base, nil, parent)
		
		frame.Width =200
		frame.Height = 400
		
		frame.Movable = true
		frame.Resizable = true
		frame.FrameStrata = "DIALOG"
		frame.Toplevel = true
		frame.MouseEnabled = true
		frame.MouseWheelEnabled = true
		frame.OnMouseDown = OnMouseDown
		frame.OnMouseUp = OnMouseUp
		
		frame:SetPoint("TOPRIGHT", parent, "TOPRIGHT", 0, -10)
		frame:SetBackdrop(_FrameBackdrop)
		frame:SetBackdropColor(0,0,0,1)
		frame:SetMinResize(200,200)
		frame:SetMaxResize(600,1000)

		local sizer_se = CreateFrame("Frame","Sizer_se",frame)
		sizer_se.Width = 10
		sizer_se.Height = 10
		sizer_se.MouseEnabled = true
		sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
		sizer_se.OnMouseDown = sizerseOnMouseDown
		sizer_se.OnMouseUp = sizerOnMouseUp
		
		local btnNew = CreateFrame("Button", "New", frame)
		btnNew.Style = "NORMAL"
		btnNew.Text = "New Addon"
		btnNew.Height = 24
		btnNew:SetPoint("TOPLEFT", frame, "TOPLEFT", 6, -10)
		btnNew:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -6, -10)
		
		local tree = CreateFrame("TreeView", "List", frame)
		tree:SetPoint("TOPLEFT", btnNew, "BOTTOMLEFT", 0, -6)
		tree:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -6, 10)
		
        return frame
    end
	
    local _WidgetInfo = {
        ["WidgetName"] = _WidgetName,
        ["Base"] = _Base,
        ["FuncProxy"] = _FuncProxy,
        ["Property"] = _Property,
        ["ScriptType"] = _ScriptType,
        ["New"] = _New,
    }
    
    _Widget[_WidgetName] = IGAS:NewWidget(_WidgetInfo)    
end